package com.ruoyi.web.controller.bl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bl.domain.BlUsersRegion;
import com.ruoyi.bl.service.IBlUsersRegionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地域区域Controller
 * 
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/bl/usersRegion")
public class BlUsersRegionController extends BaseController
{
    @Autowired
    private IBlUsersRegionService blUsersRegionService;

    /**
     * 查询地域区域列表
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlUsersRegion blUsersRegion)
    {
        startPage();
        List<BlUsersRegion> list = blUsersRegionService.selectBlUsersRegionList(blUsersRegion);
        return getDataTable(list);
    }

    /**
     * 导出地域区域列表
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:export')")
    @Log(title = "地域区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlUsersRegion blUsersRegion)
    {
        List<BlUsersRegion> list = blUsersRegionService.selectBlUsersRegionList(blUsersRegion);
        ExcelUtil<BlUsersRegion> util = new ExcelUtil<BlUsersRegion>(BlUsersRegion.class);
        util.exportExcel(response, list, "地域区域数据");
    }

    /**
     * 获取地域区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:query')")
    @GetMapping(value = "/{regionId}")
    public AjaxResult getInfo(@PathVariable("regionId") Long regionId)
    {
        return success(blUsersRegionService.selectBlUsersRegionByRegionId(regionId));
    }

    /**
     * 新增地域区域
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:add')")
    @Log(title = "地域区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlUsersRegion blUsersRegion)
    {
        return toAjax(blUsersRegionService.insertBlUsersRegion(blUsersRegion));
    }

    /**
     * 修改地域区域
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:edit')")
    @Log(title = "地域区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlUsersRegion blUsersRegion)
    {
        return toAjax(blUsersRegionService.updateBlUsersRegion(blUsersRegion));
    }

    /**
     * 删除地域区域
     */
    @PreAuthorize("@ss.hasPermi('bl:usersRegion:remove')")
    @Log(title = "地域区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionIds}")
    public AjaxResult remove(@PathVariable Long[] regionIds)
    {
        return toAjax(blUsersRegionService.deleteBlUsersRegionByRegionIds(regionIds));
    }
}
